﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Maticsoft.DBUtility;

using NVelocity;
using NVelocity.App;
using NVelocity.Context;
using NVelocity.Runtime;

using Shopping.Common;
using Shopping.Model;
using Shopping.BLL;

namespace Shopping.Tasker
{
    public class Tasker
    {
        /// <summary>
        /// 任务程序开始执行；
        /// </summary>
        public static void Start()
        {
            TasksManage bllTask = new TasksManage();
            List<TaskInfo> listOfTasks = bllTask.QueryAllTask();
            if (listOfTasks == null)
            {
                Console.WriteLine("系统未设置任何任务！");
                return;
            }
            ReturnValue ret = null;
            foreach (TaskInfo task in listOfTasks)
            {
                ret = bllTask.RunTask(task);
                if (ret.IsSucc)
                {
                    Console.WriteLine("执行成功！");
                }
                else
                {
                    Console.WriteLine("执行失败！（" + ret.Message + "）");
                }
            }
           
        }

    }
}
